<?php

class Application_Model_DbTable_Lines extends Zend_Db_Table_Abstract
{

    protected $_name = 'line';

	public function getLine($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
			if (!$row) {
				throw new Exception("Could not find row $id");
			}
			return $row->toArray();
	}
	
		public function addLine($name, $description)
		{
			$data = array(
			'name' => $name,
			'description' => $description
			);
		$this->insert($data);
		}
		
		public function updateLine($id, $name, $description)
		{
			$data = array(
			'name' => $name,
			'description' => $description
			);
		$this->update($data, 'id = '. (int)$id);
		}
		
		public function deleteLine($id)
		{
			$this->delete('id =' . (int)$id);
		}
		
		public function showLines()
		{
			$_db = Zend_Db_Table::getDefaultAdapter();
			$sql = 'SELECT id, name from line ORDER BY name';
			$result = $_db->query($sql);
			return $result;
		}
}

